package com.by.controller;


import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.LinkedList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.by.service.MainService;
import com.by.util.DataConvertor;

@Controller
public class MainController {

	@Autowired
	private MainService mainService;
    @RequestMapping(value = "/test")
    public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
        List list = mainService.getAllUsers();
        List resultList = new LinkedList<Map>();
        for (int i=0;i<list.size();i++) {  
        	Map map =(Map) list.get(i);
        	Map e =new HashMap();
        	e.put("source", map.get("SOURCE"));
        	e.put("target", map.get("TARGET"));
        	resultList.add(e);
            }
        model.addAttribute("name",name);
        model.addAttribute("list",list);
        return "test";  
    }

}